<template>
	<view class="balance">
		<!-- 头部 -->
		<!-- #ifndef MP-WEIXIN -->
		<public-header :title="title"></public-header>
		<view class="hei_100"></view>
		<!-- #endif -->
		<!-- end -->

		<view class="xian-gray16"></view>
		<view class="nav">
			<mescroll-body top="0" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback"
			 :up="upOption" :down="downOption">
				<view v-for="(item, index) in list" class="card">
					<image class="image" :src="item.posterUrl"> </image>
					<view class="body1">
						<view class="title1">
							<view class="left1">{{item.title}}</view>
						</view>
						<view class="title1">
							<view class="left2" v-if="item.enterpriseName">商家：{{item.enterpriseName}}</view>
							<view class="left2" v-else>平台通用</view>
						</view>
						<!-- <view class="name1">{{item.id}}</view>d -->
						<view class="text0" style="margin: 16rpx 0;">{{item.content}}</view>
						<view class="text1">购买价格：<text style="color: red;">￥{{item.recharge}}</text></view>
						<view class="text1">赠送：<text style="color: red;">￥{{item.couponsCount}} </text> ×{{item.coupons.price}}</view>
						<view class="time1">活动起止时间：{{item.startTime}}-{{item.endTime}}</view>
					</view>
					<view class="card-bottom" @click="pay(item)">立即购买</view>
				</view>
				<view v-if="list.length==0" class="none">
					<view class="none-body">
						<cover-image class="none-image" src="../../../static/images/null.png"></cover-image>
						<view class="none-text">暂无数据</view>
					</view>
				</view>
			</mescroll-body>
			<!-- </view> -->
		</view>
	</view>
</template>

<script>
	import PublicHeader from '@/components/PublicHeader.vue';
	import MescrollMixin from '@/components/mescroll-uni/mescroll-mixins.js';
	import MescrollBody from '@/components/mescroll-uni/mescroll-body.vue';
	import {
		mapState,
		mapMutations
	} from 'vuex';
	export default {
		mixins: [MescrollMixin],
		components: {
			PublicHeader,
			MescrollBody
		},
		computed: mapState(['hasLogin', 'uerInfo']),
		data() {
			return {
				title: '活动中心',
				panduan: true, // 判断提现明细还是订单明细
				dark: true,
				downOption: {
					auto: false // 不自动加载 (mixin已处理第一个tab触发downCallback)
				},
				upOption: {
					auto: false
				},
				id: '',
				page: 1,
				pages: 1,
				page1: 1,
				pages1: 1,
				size: 10,
				table: [],
				list: []
			}
		},
		mounted() {
			var _this = this
			console.log('uerInfo:', _this.uerInfo)
			_this.id = _this.uerInfo.userId
			if (_this.uerInfo.id) {
				_this.id = _this.uerInfo.id
			}
			_this.getData()
		},
		methods: {
			pay(item) {
				uni.navigateTo({
					url: '/pageageA/pages/balance/addmoney?type=活动&activityId=' + item.id + '&money=' + item.recharge
				})
			},
			getData() {
				let _this = this
				this.page1 = 1
				_this.$http
					.get('/user/message/center/view/activitylist', {
						page: _this.page1,
						size: _this.size,
					})
					.then(function(response) {
						if (response.success) {
							_this.list = response.data.list
							_this.pages1 = response.data.pages.list
						}
					}).catch(function(error) {
						console.log(error);
					});
			},
			//下拉刷新的回调
			downCallback() {
				var _this = this;
					_this.page1 = 1,
					_this.$http
					.get('/user/message/center/view/activitylist', {
						page: _this.page1,
						size: _this.size,
					})
					.then(function(response) {
						_this.pages1 = response.data.pages
						//联网成功的回调,隐藏下拉刷新的状态
						_this.list = response.data.list;
						_this.mescroll.endSuccess();
					})
					.catch(function(error) {
						console.log(error);
						_this.mescroll.endErr();
					});

			},
			//上拉加载的回调
			upCallback(page) {
				var _this = this;
				if (_this.page1 < _this.pages1) {
					_this.page1 = _this.page1 + 1;
					// _this.mescroll.endErr();
				} else {
					uni.showToast({
						icon: 'none',
						position: 'bottom',
						title: '没有更多数据啦~'
					});
					_this.mescroll.endErr();
					return
				}
				_this.$http
					.get('/user/message/center/view/activitylist', {
						page: _this.page1,
						size: _this.size,
					})
					.then(function(response) {
						_this.pages1 = response.data.pages
						//设置列表数据
						_this.list = _this.table.concat(response.data.list);
						_this.mescroll.endSuccess();
					})
					.catch(function(error) {
						console.log(error);
						_this.mescroll.endErr();
					});
				}
		}
	}
</script>

<style scoped lang="scss">
	page {
		/* background-color: #F9FAFB; */
	}

.msg{
	width: 91.46%;
	/* min-height: 250rpx; */
	margin-left: 4.27%;
	margin-top: 20rpx;
	border-radius: 10rpx;
	background-color: #FFFFFF;
	border:1rpx solid rgba(235,236,237,1);
	overflow: hidden;
}
.card{
	width: 91.46%;
	/* min-height: 250rpx; */
	margin-left: 4.27%;
	margin-top: 20rpx;
	overflow: hidden;
	background: #EBF7FF;
	border-radius: 10px;
	border: 1px solid #BBE3FF;
}
.msg-body {
	width: 91.2%;
	margin-left: 4.4%;
}
.title {
	margin: 30rpx 0 10rpx 0;
	font-size:32rpx;
	font-family:PingFangSC-Semibold,PingFang SC;
	font-weight:600;
	color:rgba(51,51,51,1);
}
.text {
	font-size:28rpx;
	font-family:PingFangSC-Regular,PingFang SC;
	font-weight:400;
	color:rgba(102,102,102,1);
}
.time {
	width: 100%;
	min-height: 50rpx;
	margin: 20rpx 0 30rpx 0;
	font-size:24rpx;
	font-family:PingFangSC-Regular,PingFang SC;
	font-weight:400;
	color:rgba(153,153,153,1);
}
	.top {
		/* margin-top: 100rpx; */
		margin-left: 200rpx;
		width: 350rpx;
		height: 100rpx;
		/* background-color: pink; */
		font-size: 28rpx;
		font-family: PingFangSC-Medium, PingFang SC;
		font-weight: 600;
		color: rgba(102, 102, 102, 1);
	}

	.top-text1 {
		height: 40rpx;
		line-height: 40rpx;
		margin-top: 30rpx;
	}

	.top-text2 {
		height: 40rpx;
		line-height: 40rpx;
		margin-top: 30rpx;
		color: $uni-color1;
		border-bottom: $uni-color1 4rpx solid;
	}

	.cont {
		display: flex;
		height: 100rpx;
		color: #fff;
		font-size: 36rpx;
		line-height: 50rpx;
		text-align: left;
		padding-top: 38rpx;
		padding-bottom: 30rpx;
		background-color: $uni-color1;
	}

	.cont>view {
		padding: 0 180rpx 0 30rpx;
	}

	.cont>view:first-child {
		border-right: 1rpx solid rgba(255, 255, 255, 0.4);
	}

	.cont>view .tit {
		font-size: 24rpx;
		line-height: 33rpx;
		margin-bottom: 10rpx;
	}

	.nav {
		width: 100%;
		background-color: #FFFFFF;
	}

	.nav-list {
		width: 100%;
		/* margin-left: 4%; */
		/* height: 104rpx; */
		/* line-height: 104rpx; */
		font-size: 34rpx;
		color: #666;
		border-bottom: 1rpx solid #DFDFDF;
	}

	.nav-list:last-child {
		border: 0 none;
	}

	.nav-list .fr .fl {
		color: #888;
		font-size: 28rpx;
	}

	.nav-list .fr {
		font-size: 30rpx;
		color: #333;
	}

	.nav-list .fr image {
		width: 13rpx;
		margin-left: 20rpx;
		margin-top: 42rpx;
	}

	.nav-list .fr .portrait {
		width: 66rpx;
		height: 66rpx;
		border-radius: 100%;
		background-color: #999;
		margin-top: 20rpx;
	}

	.text1 {
		/* padding-top: 22rpx; */
		height: 33rpx;
		font-size: 24rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: rgba(102, 102, 102, 1);
		line-height: 33rpx;
	}

	.text2 {
		padding-bottom: 22rpx;
		height: 33rpx;
		font-size: 24rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: rgba(102, 102, 102, 1);
		line-height: 33rpx;
	}
	.image{
		width: 100%;
		height: 253rpx;
		box-shadow: 0 1px 18px 0 rgba(0, 0, 0, 0.06)
	}
	.body1{
		padding: 30rpx;
	}
	.title1{
		width: 100%;
		min-height: 45rpx;
	}
	.left1{
		float: left;
		/* line-height: 45rpx; */
		font-size:32rpx;
		font-family:PingFangSC-Semibold,PingFang SC;
		font-weight:600;
		color:rgba(51,51,51,1);
	}
	.left2{
		float: left;
		/* line-height: 45rpx; */
		font-size:24rpx;
		font-family:PingFangSC-Semibold,PingFang SC;
		font-weight:500;
		color:rgba(51,51,51,1);
	}
	.right1{
		float: right;
		font-size:24rpx;
		font-family:PingFangSC-Regular,PingFang SC;
		font-weight:400;
		color:rgba(153,153,153,1);
		/* line-height:33rpx; */
	}
	.name1{
		width: 100%;
		/* height:33rpx; */
		font-size:24rpx;
		font-family:PingFangSC-Regular,PingFang SC;
		font-weight:400;
		color:rgba(153,153,153,1);
		/* line-height:33rpx; */
	}
	.text0 {
		/* margin: 20rpx 0; */
		width: 100%;
		overflow: hidden;
		/* min-height:40rpx; */
		font-size:28rpx;
		font-family:PingFangSC-Regular,PingFang SC;
		font-weight:400;
		color:rgba(102,102,102,1);
		/* line-height:40rpx; */
	}
	.text1 {
		/* margin: 20rpx 0; */
		width: 100%;
		/* min-height:40rpx; */
		font-size:28rpx;
		font-family:PingFangSC-Regular,PingFang SC;
		font-weight:400;
		color:rgba(102,102,102,1);
		/* line-height:40rpx; */
	}
	.time1{
		width:100%;
		/* height:33rpx; */
		font-size:24rpx;
		font-family:PingFangSC-Regular,PingFang SC;
		font-weight:400;
		color:#9697FC;
		/* line-height:33rpx; */
	}
	.card-bottom{
		width: 100%;
		height: 68rpx;
		background: linear-gradient(135deg, #98D7FF 1%, #B7B5F6 100%);
		border-radius: 10px;
		font-size: 28rpx;
		font-family: PingFangSC-Medium, PingFang SC;
		font-weight: 500;
		color: #FFFFFF;
		display: flex;
		justify-content: center;
		align-items: center;
		}
</style>
